#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int d[N],v[N],a[N];
int p[N];
bool rm[N];
int main(){
   freopen("detect.in","r",stdin);
   freopen("detect.out","w",stdout);
   ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
        int n,m,l,vsd;
        int cnt=0;
        cin>>n>>m>>l>>vsd;
        for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)cin>>p[i];

        for(int i=1;i<=n;i++){
            bool flag=0;
            int k=0,vs=v[i],sum=d[i];
            while(sum<=l&&vs>0){
                if((vs>vsd&&a[i]>=0)||(vs+((k+1)*a[i])>vsd&&a[i]<0)){
                        int summ=sum+v[i]+(k*a[i]);
                        for(int j=1;j<=m;j++){
                            if(p[j]>=sum&&p[j]<=summ){
                                int s=p[j]-d[i];
                                double vsn=sqrt(v[i]*v[i]+2*a[i]*s);
                                if(vsn>vsd){
                                    rm[j]=1;
                                    flag=1;
                                    cnt++;
                                    break;
                                }
                            }
                    }
                }
                if(flag)break;
                vs=v[i]+((k++)*a[i]);
                sum+=vs;

            }
        }
        int tmp=0;
        for(int i=1;i<=m;i++){
            if(rm[i])tmp++;
        }
        cout<<cnt<<' '<<m-tmp<<endl;
    }
return 0;
}
